home *** CD-ROM | disk | FTP | other *** search
- Path: news.polymtl.ca!news
- From: Pierre Ferland <pierre@meca.polymtl.ca>
- Newsgroups: comp.lang.c++
- Subject: templates and incomplete classes
- Date: Wed, 03 Apr 1996 13:23:35 -0500
- Organization: Center for Applied Research on Polymers
- Message-ID: <3162C227.446B@meca.polymtl.ca>
- NNTP-Posting-Host: crasp.meca.polymtl.ca
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.01 (X11; I; AIX 2)
-
- I have the following templates-related compiling problem:
-
- Say that you have a ``List_t<class T>'' template, to handle lists
- whatever they are. The template is declared and defined in a ``list.H''
- file:
-
- template <class T> List_t {
- private:
- T member_Object;
- public:
- List_t();
- };
-
- Now, a programmer defines a class which handles lists of itslef,
- please do not ask me why:
-
- #include "list.H"
- class Buggy_c {
-
-
- private:
- List_t < Buggy_c > member_myOwnList;
-
- };
-
- Now depending upon the compiler used, we may or may not have incomplete
- type problems.
-
- - AIX's xlC c++ compiler works fine. (surprising, isn't it ?)
- - SGI's native CC compiler works fine
- (had to release from previous cfront version)
- - gcc (version 2.7.2) shoots an incomplete type error,
- during the instantiation
- of List_t < Buggy_c >, apparently because Buggy_c is an
- incomplete type till List_t < Buggy_c > is completely
- defined, which obviously will not happen!
-
- Does anyone have the smallest idea how I could have the compiler
- go through this?
-
- From the time I've been using templates on, I always got
- either compilation or link or readability problems.
- Are these templates really worth the effort or is it another
- unusable C++ feature we should forbid for serious
- developments ?
-
-
- Pierre Ferland (pierre@.meca.polymtl.ca)
-